<?php
 class Admin_Model_User extends Zend_Db_Table_Abstract{
 	protected $_name = "vms_users";
	protected $_primary = "id";
	
	public function view(){	
		$query = $this->select()
             ->from( 'vms_users' )
			 ->where('id_group = ?',0);
		$data = $this-> fetchAll($query);
		return $data -> toArray();
	}
	
	public function view_where($id){	
		$query = $this->select()
             ->from( 'vms_users' )
			 ->where('id = ?',$id);
		$data = $this-> fetchAll($query);
		return $data -> toArray();
	}
	
	public function profile($id){	
		$query = $this->select()
             ->from( 'vms_users' )
			 ->where('id = ?',$id);
		$data = $this-> fetchAll($query);
		return $data -> toArray();
	}
	
	public function add($data){
		$this->insert($data);
	}
	
	public function edit($id,$data){
		$where = "id=".$id;
		$this->update($data,$where);
	}
	
	public function lock($id,$data){
		$where = "id=".$id;
		$this->update($data,$where);
	}

	public function check($email){
		$query = $this -> select();
		$query->from('vms_users',array('email'));
		$query->where('email= ?', $email);
		$data = $this-> fetchAll($query);
		$row = $data ->toArray(); 
		if($row == NULL){
			return true;
		}else{
			return false;
		}
	}
 }